package com.qf.controller;

import com.qf.pojo.User;
import com.qf.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 千锋健哥
 */
@RestController
@RequestMapping("/test")
@Api(description = "测试类TestController", value = "测试类")
public class TestController {

    @Autowired
    private User user;

    @Value("${aliyun.userName}")
    private String userName;

    @Value("${aliyun.password}")
    private String password;

    @Autowired
    private UserService userService;

    @GetMapping("/t1")
    @ApiOperation(value = "测试方法hello")
    public String hello(
                    //@ApiParam(value = "用户名") String userName,
                    @RequestBody User user) {

        System.out.println("========="+ userName);
        System.out.println("========="+password);
        System.out.println(user);
        return "hello world";
    }

    @RequestMapping("/list")
    public List<User> findAll() {
        List<User> list = userService.findAll();
        return list;
    }

    @PostMapping("/add")
    public String addUser(@RequestBody User user) {
        userService.insertUser(user);
        return "保存成功!";
    }
}
